//
//  ViewController.m
//  MMDrawerController-test
//
//  Created by 徐悟源 on 16/4/5.
//  Copyright © 2016年 徐悟源. All rights reserved.
//

#import "ViewController.h"
#import "MMDrawerController.h"
#import "MMDrawerBarButtonItem.h"
#import "UIViewController+MMDrawerController.h"

/** all for test */

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"左边栏" style:UIBarButtonItemStyleDone target:self action:@selector(leftClick)];
//    
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"右边栏" style:UIBarButtonItemStyleDone target:self action:@selector(rightClick)];
    
    // 用系统自带的设置NavigationItem按钮的方法和这个库自带的都可以
    [self setupLeftMenuButton];
    [self setupRightMenuButton];
    
    self.view.backgroundColor = [UIColor redColor];
    
}

- (void)setupLeftMenuButton
{
    MMDrawerBarButtonItem *leftBarButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(leftClick)];
    
    self.navigationItem.leftBarButtonItem = leftBarButton;
}

- (void)setupRightMenuButton
{
    MMDrawerBarButtonItem *rightBarButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(rightClick)];
    self.navigationItem.rightBarButtonItem = rightBarButton;
}

- (void)leftClick
{
    // 推出或者关闭抽屉，MMDrawerController自己会管理
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}

- (void)rightClick
{
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
